package com.atguigu.daijia.customer.controller;

import com.atguigu.daijia.common.login.GuiguLogin;
import com.atguigu.daijia.common.result.Result;
import com.atguigu.daijia.common.util.AuthContextHolder;
import com.atguigu.daijia.customer.client.CustomerInfoFeignClient;
import com.atguigu.daijia.customer.service.CustomerService;
import com.atguigu.daijia.model.form.order.StartDriveForm;
import com.atguigu.daijia.model.vo.customer.CustomerLoginVo;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.web.bind.annotation.*;

@Slf4j
@Tag(name = "客户API接口管理")
@RestController
@RequestMapping("/customer")
@SuppressWarnings({"unchecked", "rawtypes"})
public class CustomerController {




    @Resource
    CustomerService customerInfoService;

    @Resource
    RedisTemplate redisTemplate;

    @Resource
    CustomerInfoFeignClient customerInfoFeignClient;


    @Operation(summary = "获取客户基本信息")
    @GuiguLogin
    @GetMapping("/getCustomerLoginInfo")
    public Result<CustomerLoginVo> getCustomerLoginInfo(){

        Long customerId = AuthContextHolder.getUserId();
        //从请求头里获取token字符串

        CustomerLoginVo customerLoginVo = customerInfoService.getCustomerInfo(customerId);

        //返回用户信息
        return Result.ok(customerLoginVo);
    }



//    @Operation(summary = "获取客户基本信息")
//    @GuiguLogin
//    @GetMapping("/getCustomerLoginInfo")
//    public Result<CustomerLoginVo> getCustomerLoginInfo(@RequestHeader(value = "token") String token){
//        //从请求头里获取token字符串
//
//        CustomerLoginVo customerLoginVo = customerInfoService.getCustomerLoginInfo(token);
//
//        //返回用户信息
//        return Result.ok(customerLoginVo);
//    }

    @Operation(summary = "小程序授权登录")
    @GetMapping("/login/{code}")
    public Result<String> wxLogin(@PathVariable String code){
        return Result.ok(customerInfoService.login(code));
    }




}

